package com.example.demo.controller;

import com.example.demo.entity.Student;
import com.example.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @ResponseBody
    @RequestMapping(value = "/register",method = RequestMethod.POST)
    public Map<String,Object> studentRegister(@RequestBody Student student){
        Map<String ,Object> retData = new HashMap<>();
        if(student.getUsername().isEmpty() || student.getStudentId().isEmpty() || student.getPassword().isEmpty()){
            retData.put("code",500);
            retData.put("message","参数错误！");
            return retData;
        }else
            return studentService.studentRegist(student);

    }


}
